<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <title>样机管理首页</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="refresh" content="1200">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=86e2297f">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=222aea35">
    <link rel="stylesheet" href="/dist/plugins/fixedTable/fixed-table.css"/>
    <style>
        .table > tbody > tr > td {
            height: 35px;
            max-height: 44px;
            overflow: hidden;
            padding: 0 2px;
            text-align: left
        }

        .saveModle {
            width: 500px;
            height: 300px;
            position: fixed;
            top: 50%;
            left: 50%;
            margin-left: -250px;
            margin-top: -150px;
            background: #fff;
            border-radius: 10px;
            z-index: 1978;
            display: none;
            border: 1px solid #cfcfcf;
        }

        .saveModle .top {
            height: 34px;
            line-height: 34px;
            font-size: 14px;
            font-weight: bold;
            color: #333;
            padding-left: 7px;
            border-bottom: 1px solid #cfcfcf;
            background: #fff;
        }

        .saveModle .top .title {
            height: 32px;
            line-height: 32px;
            font-size: 14px;
            font-weight: bold;
            color: #333;
            float: left;
            background: #fff;
        }

        .saveModle .top .btn {
            font-size: 20px;
            width: 34px;
            height: 22px;
            line-height: 12px;
            display: inline-block;
            float: right;
        }

        .saveModle .top .btn:hover {
            color: red;
        }

        .saveModle .saveBtn {
            margin: 0 auto;
            margin-top: 35px;
            display: block;

        }

        .lineOne {
            text-align: left;
        }

        .lineOne span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }

        p {
            display: inline-block;
            float: left;
            margin-bottom: 0px;
            line-height: 25px;
            padding-right: 15px;
            color: #228bee;
            font-size: 14px;
        }

        .td-value span.lineOne {
            overflow: hidden;
            text-overflow: ellipsis;
            color: black !important;
            /*display: -webkit-box;*/
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            max-height: 34px;
        }

        .td-value {
            text-align: left !important;
            vertical-align: middle;
            word-wrap: break-word;
            color: black !important;
        }

        td {
            height: 47.78px;
        }

        .td-value span {
            display: inline-block;
            overflow: hidden;
            padding-left: 0.06rem;
            word-wrap: break-word;
            color: black !important;
        }

        /*span.lineOne {*/
        /*line-height: 30px;*/
        /*height: 30px;*/
        /*overflow: hidden;*/
        /*text-overflow: ellipsis;*/
        /*display: -webkit-box;*/
        /*-webkit-box-orient: vertical;*/
        /*-webkit-line-clamp: 1;*/
        /*}*/
        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }

        .fixed-table_body tr td {
            border-right: none;
            font-size: 12px;
            text-align: center;
        }

        .fixed-table_header tr th {
            border-right: none;
            background: yellow;
            font-weight: normal;
            font-size: 12px;
        }

        .nav > li > a {
            padding: 10px 10px;
        }

        .content {
            padding: 0;
        }

        .nav-tabs-custom > .nav-tabs > li.active {
            color: #2a8cec;
        }

        .nav-tabs-custom > .nav-tabs > li.active > a, .nav-tabs-custom > .nav-tabs > li.active:hover > a {
            background: #fff;
            color: #2a8cec;
            border-top-left-radius: 0px;
            border-top-right-radius: 0px;
        }

        .nav-tabs {
            border-bottom: 0px solid #ddd;
        }

        .nav-tabs-custom > .nav-tabs {
            /*border-bottom-color: #fff;*/
        }

        .nav-tabs-custom {
            box-shadow: 0 0px 0px rgba(0, 0, 0, 0.1);
        }
        .fixed-table-box .fixed-table_header th{
            text-align: center;
        }
        .fixed-table-box td{
            height:35px;
        }
    </style>
</head>
<body style="overflow-y:hidden">
<iframe id="ifExprot" style="width:0px;height:0px;display: none;" frameborder="0"></iframe>

<section class="content" id="app" v-cloak>
    <div class="oaLoad">
        <div class="loadGif" id="areaProgress" style="margin-left: -70px"></div>
    </div>
    <div class="div-td-content-more"><i></i></div>

    <div class="nav-tabs-custom oaReportNav" style="margin:10px 0px;">
        <!--下拉框联动-->
        <div class="pull-left" style="width:130px;">
            <select id="testCom" v-model="selectCom" class="form-control" @change="getBran"
                    style="height:26px;width: 130px;font-size:12px;line-height:25px;padding-top:0px;padding-bottom:0px;padding-left:6px;">
                <option selected value="购车公司">购车公司</option>
                <option v-for="itemC in itemsCom" v-bind:value="itemC.id">{{itemC.name}}</option>
            </select>
        </div>
        <div class="pull-left" style="margin-left:10px;">
            <select id="testBran" v-model="selectBran" class="form-control"
                    style="height:26px;width: 130px;font-size:12px;line-height:25px;padding-top:0px;padding-bottom:0px;padding-left:6px;"
                    @change="getType">
                <option selected value="品牌">品牌</option>
                <option v-for="itemB in itemsBran" v-bind:value="itemB.id">{{itemB.brandName}}</option>
            </select>
        </div>

        <div class="pull-left" style="width:130px;margin-left:10px;">
            <select id="testType" v-model="selectType" class="form-control" @change="getMod"
                    style="height:26px;width: 130px;font-size:12px;line-height:25px;padding-top:0px;padding-bottom:0px;padding-left:6px;">
                <option selected value="设备类型">设备类型</option>
                <option v-for="itemT in itemsType" v-bind:value="itemT.id">{{itemT.name}}</option>
            </select>
        </div>
        <div class="pull-left" style="margin-left: 10px;">
            <select id="testMod" v-model="selectMod" class="form-control"
                    style="height:26px;width: 130px;font-size:12px;line-height:25px;padding-top:0px;padding-bottom:0px;padding-left:6px;"
                    @change="show()">
                <option selected value="型号">型号</option>
                <option v-for="itemMo in itemsMod" v-bind:value="itemMo.id">{{itemMo.modelName}}</option>
            </select>
        </div>
        <div class="pull-left" style="margin-left: 10px;">
            <select id="testState" v-model="selectState" class="form-control"
                    style="height:26px;width: 130px;font-size:12px;line-height:25px;padding-top:0px;padding-bottom:0px;padding-left:6px;">
                <!--@change="search()"-->
                <option selected value="状态">状态</option>
                <option v-for="option in stateList" v-bind:value="option.value">{{option.name}}</option>
            </select>
        </div>
        <div class="pull-left divCheck" style="margin-left: 10px;">
            <input type="checkbox" id="cbCheck" v-model="settle" >是否结清
            <!--@click="searchAll()"-->
        </div>
        <div class="has-feedback">
            <input type="text" id="likeSelect" class="form-controll pull-left input-sm"
                   style="width: 130px;height: 25px;margin-left: 5px;" v-model="key" placeholder="请输入关键字"
                   size="12">
            <span id="btnQuery" class="glyphicon glyphicon-search form-control-feedback"
                  style="display:none "></span>
            <input type="button" class="btn oaBtn pull-left btn-sm" style="margin-left: 10px" value="查询"
                   class="oaBtn" @click="sel()">
        </div>
        <div class="pull-left" style="margin-left: 10px;">
            <button type="button" class="btn oaBtn pull-right btn-sm"
                    @click="addNewSample()" id="add"/>
            新增入库</button>
        </div>
        <div class="pull-left" style="margin-left: 10px;">
            <button type="button" class="btn oaBtn pull-right btn-sm"
                    @click="exportExcel()" id="export"/>
            导出新机</button>
        </div>
    </div>
    <div class="box-body no-padding" style="overflow: auto;margin-top:10px;display: inline-block; " id="scrollDiv">
        <div id="progress" class="wyui-progress"></div>
        <div class="fixed-table-box head-fixed" v-if="partTime.indexOf('订货支持')>=0||partTime.indexOf('后台管理')>=0">
            <!-- 表头 start -->
            <div class="fixed-table_header-wraper"  >
                <table class="fixed-table_header" cellspacing="0" cellpadding="0" border="0" >
                    <thead style="width: 100%">
                    <tr style="">
                        <th style="width: 2.5%;">
                            序号
                        </th>
                        <th style="width: 5%;text-align: left">
                            提货日期
                        </th>
                        <th style="width: 6.4%;text-align: left;">
                            购车公司
                        </th>
                        <th style="width: 4.5%;text-align: left;">
                            品牌
                        </th>
                        <th style="width: 5%;text-align: left;">
                            型号
                        </th>
                        <th style="width: 11.9%;text-align: left;">
                            序列号
                        </th>
                        <th style="width: 4.2%;text-align: left;">
                            斗容
                        </th>
                        <th style="width: 5.7%;text-align: left;">
                            铲斗类型
                        </th>
                        <th style="width: 5%;">
                            生产日期
                        </th>
                        <th style="width: 6.3%;">
                            交车日期
                        </th>
                        <th style="width: 4.2%;text-align: left;">
                            库存地
                        </th>
                        <th style="width: 4.7%;">
                            库存状态
                        </th>
                        <th style="width: 6.3%;">
                            预计付<br>款日期
                        </th>
                        <th style="width: 6.3%;text-align: left;">
                            预计付<br>款金额
                        </th>
                        <th style="width: 4%;">
                            结清
                        </th>
                        <th style="width: 6.8%;">
                            审核状态
                        </th>
                        <th style="width: 11.2%">
                            操作
                        </th>
                        <th style="width: 17px"></th>
                    </tr>
                    </thead>
                </table>
            </div>
            <!--内容-->
            <div class="fixed-table_body-wraper iframeKC">
                <table class="fixed-table_body table-hover" cellspacing="0" cellpadding="0" border="0"
                       style="width: 100%;table-layout: fixed">
                    <tbody id="tbList">
                    <tr v-for="(item,i) in list">
                        <td style="width: 2.5%;">{{i+1}}</td>
                        <td style="width: 5%;text-align: left">
                            <!--<span v-if="item.pickUpDate">{{formatDate(item.pickUpDate+" 00:00:00")}}</span>-->
                            <span v-if="item.pickUpDate">{{item.pickUpDate.substring(2)}}</span>
                            <span v-else>-</span>

                        </td>
                        <td style="width: 6.4%;text-align: left;"class="lineOne" ><span>{{item.companyName}}</span></td>
                        <td style="width: 4.5%;text-align: left;">
                            {{item.brandName}}
                        </td>
                        <td style="width: 5%;text-align: left;" class="lineOne"><span >{{item.modelName}}</span></td>
                        <td  @click="gotoDetailSel(item)" style="color: #2a8cec;cursor: pointer;width: 11.9%;text-align: left;">
                            {{item.sequence}}
                        </td>
                        <td style="width: 4.2%;" class='td-tanZongStyle-line'><span
                                class="lineOne">{{item.bucketCapacity}}</span></td>
                        <td style="width: 5.7%;" class='td-tanZongStyle-line'><span
                                class="lineOne">{{item.bucketType}}</span></td>
                        <td style="width: 5%;">
                            <!-- <span v-if="item.productionDate">{{formatDate(item.productionDate+" 00:00:00")}}</span>-->
                            <span v-if="item.productionDate" style="text-align: left">{{item.productionDate.substring(2)}}</span>
                            <span v-else>-</span>
                        </td>
                        <td style="width: 6.3%;">
                            <!--<span v-if="item.actualDeliveryDate">{{formatDate(item.actualDeliveryDate+" 00:00:00")}}</span>-->
                            <span v-if="item.actualDeliveryDate" style="text-align: left">{{item.actualDeliveryDate.substring(2)}}</span>
                            <span v-else>-</span>
                        </td>
                        <td style="width: 4.2%;" class='td-tanZongStyle-line'><span v-html="showDz(item)"
                                                                                    class="lineOne"></span></td>
                        <td style="width: 4.7%;" v-html="convertAuditFlagToName(item)">

                        </td>
                        <td style="width:6.3%;" >
                            <!--<span v-if="item.expirationDate">{{formatDate(item.expirationDate+" 00:00:00")}}</span>-->
                            <span v-if="item.expirationDate" style="text-align: left">{{item.expirationDate.substring(2)}}</span>
                            <span v-else>-</span>
                        </td>
                        <td style="width: 6.3%;text-align: left;" >{{fmoney(item.expirationMoney)}}</td>
                        <td style="width: 4%;" v-if="item.settle=='是'">
                            {{item.settle}}
                        </td>
                        <td style="width:4%;" v-else>-</td>
                        <td style="width: 6.8%;" v-if="item.auditFlag=='-1'">-</td>
                        <td style="width: 6.8%;" v-else-if="item.auditFlag=='0'">
                            <span style="color:red;">待审核</span>
                        </td>
                        <td style="width: 6.8%;" v-else-if="item.auditFlag=='1'">已通过</td>
                        <td style="width: 6.8%;" v-else-if="item.auditFlag=='2'">已驳回</td>

                        <td style="width:11.2%;">
                            <a @click="gotoDetailSh(item.id)" :id="i" v-if="showButton('审核',item)"
                               style="cursor: pointer;">&nbsp;审核&nbsp;</a>
                            <a style="text-align: center;color: #CCCCCC" v-else>&nbsp;审核&nbsp;</a>
                            <a @click="gotoDetail(item)" v-if="showButton('编辑',item)" style="cursor: pointer">&nbsp;编辑&nbsp;</a>
                            <a style="text-align: center;color: #CCCCCC" v-else>&nbsp;编辑&nbsp;</a>
                            <a @click="del(item.id)" v-if="showButton('删除',item)"
                               style="cursor: pointer">&nbsp;删除&nbsp;</a>
                            <a style="text-align: center;color: #CCCCCC" v-else>&nbsp;删除&nbsp;</a>
                            <br/>
                            <a v-if="showABtn(item)" @click="gotoDetailOut(item,'out')"
                               style="cursor: pointer">出库&nbsp;</a>
                            <a style="text-align: center;color: #CCCCCC" v-else>出库&nbsp;</a>
                            <a v-if="showABtn(item,'move')" @click="gotoDetailOut(item,'move')" style="cursor: pointer">&nbsp;移库&nbsp;</a>
                            <a style="text-align: center;color: #CCCCCC" v-else>&nbsp;移库&nbsp;</a>
                            <a v-if="showABtn(item,'exit')" @click="gotoDetailOut(item,'exit')" style="cursor: pointer">&nbsp;退货&nbsp;</a>
                            <a style="text-align: center;color: #CCCCCC" v-else>&nbsp;退货&nbsp;</a>
                        </td>


                        <template v-if="list.length>=18">
                            <td style="width: 0px;"></td>
                        </template>
                        <template v-else>
                            <td style="width: 17px;" ></td>
                        </template>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="fixed-table-box head-fixed" v-else="">
            <!-- 表头 start -->
            <div class="fixed-table_header-wraper"  >
                <table class="fixed-table_header" cellspacing="0" cellpadding="0" border="0" >
                    <thead style="width: 100%">
                    <tr style="">
                        <th style="width:3%;">
                            序号
                        </th>
                        <th style="width: 7%;text-align: left">
                            提货日期
                        </th>
                        <th style="width: 8%;text-align: left;">
                            购车公司
                        </th>
                        <th style="width: 6%;text-align: left;">
                            品牌
                        </th>
                        <th style="width: 8%;text-align: left;">
                            型号
                        </th>
                        <th style="width: 14%;text-align: left;">
                            序列号
                        </th>
                        <th style="width: 5%;text-align: left;">
                            斗容
                        </th>
                        <th style="width: 6%;text-align: left;">
                            铲斗类型
                        </th>
                        <th style="width: 8%;text-align: left">
                            生产日期
                        </th>
                        <th style="width: 8%;text-align: left">
                            实际交车日期
                        </th>
                        <th style="width: 5%;text-align: left;">
                            库存地
                        </th>
                        <th style="width: 6%;">
                            库存状态
                        </th>
                        <th style="width: 8%;">
                            审核状态
                        </th>
                        <th style="width: 8%">
                            操作
                        </th>
                        <th style="width: 17px"></th>
                    </tr>
                    </thead>
                </table>
            </div>
            <!--内容-->
            <div class="fixed-table_body-wraper iframeKC">
                <table class="fixed-table_body table-hover" cellspacing="0" cellpadding="0" border="0"
                       style="width: 100%;table-layout: fixed">
                    <tbody id="tbList">
                    <tr v-for="(item,i) in list">
                        <td style="width: 3%;">{{i+1}}</td>
                        <td style="width: 7%;text-align: left">
                            <span v-if="item.pickUpDate">{{item.pickUpDate.substring(2)}}</span>
                            <span v-else>-</span>
                        </td>
                        <td style="width: 8%;text-align: left;"class="lineOne" ><span>{{item.companyName}}</span></td>
                        <td style="width: 6%;text-align: left;">
                            {{item.brandName}}
                        </td>
                        <td style="width: 8%;text-align: left;" class="lineOne"><span >{{item.modelName}}</span></td>
                        <td  @click="gotoDetailSel(item)" style="color: #2a8cec;cursor: pointer;width: 14%;text-align: left;">
                            {{item.sequence}}
                        </td>
                        <td style="width: 5%;" class='td-tanZongStyle-line'><span
                                class="lineOne">{{item.bucketCapacity}}</span></td>
                        <td style="width: 6%;" class='td-tanZongStyle-line'><span
                                class="lineOne">{{item.bucketType}}</span></td>
                        <td style="width: 8%;text-align: left">
                            <span v-if="item.productionDate">{{item.productionDate.substring(2)}}</span>
                            <span v-else>-</span>
                        </td>
                        <td style="width:8%;text-align: left">
                            <span v-if="item.actualDeliveryDate">{{item.actualDeliveryDate.substring(2)}}</span>
                            <span v-else>-</span>
                        </td>
                        <td style="width: 5%;" class='td-tanZongStyle-line'><span v-html="showDz(item)"
                                                                                  class="lineOne"></span></td>
                        <td style="width: 6%;" v-html="convertAuditFlagToName(item)">

                        </td>

                        <td style="width: 8%;" v-if="item.auditFlag=='-1'">-</td>
                        <td style="width: 8%;" v-else-if="item.auditFlag=='0'">
                            <span style="color:red;">待审核</span>
                        </td>
                        <td style="width: 8%;" v-else-if="item.auditFlag=='1'">已通过</td>
                        <td style="width: 8%;" v-else-if="item.auditFlag=='2'">已驳回</td>
                        <td style="width:8%;">
                            <a @click="gotoDetail(item)" v-if="showButton('编辑',item)" style="cursor: pointer">&nbsp;编辑&nbsp;</a>
                            <a style="text-align: center;color: #CCCCCC" v-else>&nbsp;编辑&nbsp;</a>
                            <a v-if="showABtn(item) && isShow(item)" @click="gotoDetailOut(item,'move')" style="cursor: pointer">&nbsp;移库&nbsp;</a>
                            <a style="text-align: center;color: #CCCCCC" v-else>&nbsp;移库&nbsp;</a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <!-- /.box-body -->
</section>
<!--JQ-->
<script src="/dist/plugins/jQuery/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="/dist/plugins/bootstrap/js/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=8e743a31"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=54c6b89c"></script>
<script type="text/javascript" src="/dist/plugins/vue/vue.js"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script src="/dist/plugins/fixedTable/fixed-table.js"></script>
<script>
    $(function () {
        $("body").on("click", ".lineOne", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                var width = $(this).outerWidth();
                if (width < 180) {
                    width = 180;
                }
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": width + "px",
                        "left": $(this).offset().left,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
</script>
<script type="text/javascript">

    function refresh() {
        window.location.href = "list.html";
    }

    var app = new Vue({
        el: '#app',
        data: {
            //移库的公司
            userRoles:{},
            Tag: 1,
            currentUser: getCurrentUser(),
            roleName: getCurrentUser().roleName,
            partTime:getCurrentUser().roleName,
            userId: getCurrentUser().id,
            selectCom: "购车公司",
            selectBran: "品牌",
            selectMod: "型号",
            selectType: "设备类型",
            selectState: "状态",
            key: '',
            stateList: [
                {name: '全部', value: '全部'},
                {name: '未发订单', value: '未发订单'},
                {name: '提车在途', value: '提车在途'},
                {name: '库存', value: '库存'},
                {name: '待出库',value: '待出库'},
                {name: '交付在途', value: '交付在途'},
                {name: '已交', value: '已交'},
                {name: '移库在途', value: '移库在途'},
                {name: '退货在途', value: '退货在途'},
                {name: '已退货', value: '已退货'},
            ],
            isOk: "",
            itemsType: [],
            itemsCom: [],
            itemsBran: [],
            itemsMod: [],
            itemState: [],
            pickUpAddressList: [],
            searchParams: {
                state: '',
            },
            num: {
                allNum: '',
                outNum: '',
                no: '',
                getNow: '',
                moveNow: '',
                outNow: '',
                exitNum: '',
                exitNow: '',
                willOutBound:''
            },
            list: [],
            settle: false,
            sampleParmsList: {
                main: {
                    modelName: "",
                }
            }
        },
        methods: {
            formatDate: function (now) {
                return NewDate(now).Format(TimeFormat.pcListYR);
            },
            fmoney: function (s, n) {
                n = n > 0 && n <= 20 ? n : 2;
                s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";
                var l = s.split(".")[0].split("").reverse(), r = s.split(".")[1],
                    t = "";
                for (i = 0; i < l.length; i++) {
                    t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");
                }
                return t.split("").reverse().join("") + "." + r;
            },
            //是否结清
            searchAll: function () {
                var that = this;
                var obj;
                if (that.settle) {
                    obj = "";
                } else {
                    obj = "是";
                }
                var data = {
                    'settle': obj,
                }
                $.wyui.postMethod('/deviceSampleNew/getDeviceSampleList.json', trimRN(data), function (r) {
                    that.list = r.records;
                })
            },
            exportExcel: function () {
                $.dialog({
                    content: 'url:/page/device/sample/sampleExport.html',
                    title: "新机导出",
                    width: 1000,
                    height: 700,
                    max: true,
                    min: true,
                    lock: true
                });
                /*var that = this;
                $('#ifExprot').attr('src', server.ip
                    + "/deviceSample/getDownByCondition.json"
                );*/
            },
            showDz: function (item) {
                var html = item.storeAddress;
                if (html == "直发客户交机") {
                    return html;
                } else {
                    var sta = html.indexOf("省");
                    var pos = html.indexOf("市");
                    return html.substring(sta + 1, pos + 1);
                }
            },
            itemIndexOf:function (roleName,item) {
                var that = this;
                return that.partTime.indexOf(roleName + item.newCompanyId)>=0 || that.partTime.indexOf(roleName + "201712161613432EAF27DBCCB7D0E6CA")>=0;
            },
            showButton: function (type, item) {
                var userId = getCurrentUser().id;
                var roleName = getCurrentUser().roleName;
                var name = getCurrentUser().name;
                var that = this;
                /*驳回状态，订货支持不能操作*/
                if( that.itemIndexOf("订货支持",item)&& item.auditFlag == '2'){
                    return false;
                }
                /*审核按钮只有订货支持能操作，并且只有在审核状态下才能操作*/
                if (that.itemIndexOf("订货支持",item) && item.auditFlag == "0") {
                    return type == '审核';
                }
                /*删除按钮，只有订货支持能操作，并且只有在审核、已交、退货在途中不可以删除*/
                if (type == '删除') {
                    return that.itemIndexOf("订货支持",item) && item.auditFlag != "0" && item.state != '已交'&& item.state!='退货在途';
                }
                if (type == '编辑' && item.auditFlag != '0' ) {
                    /*非审核状态才可以编辑*/
                    if(that.itemIndexOf("订货支持",item)){
                        var t_state = '交付在途,已交,移库在途,退货在途,库存,寄存';
                        return (
                            (
                                item.state=='未发订单'
                            )
                            ||
                            (
                                item.state=='提车在途'
                                &&
                                item.auditFlag=='-1'
                            )
                            ||
                            (
                                t_state.indexOf(item.state)>=0
                                &&
                                (
                                    item.auditFlag=='1'
                                    ||
                                    item.auditFlag=='-1'
                                )
                            )
                        );
                    }
                    /*
                        如果购车公司不等于归属公司，并且当前人公司等于购车公司
                        归属公司人员一直能够看到，但是不能操作
                    */
                    if((item.fkcompanyId!=item.newCompanyId)&&that.partTime.indexOf(item.fkcompanyId)>=0){
                        return false;
                    }
                    /*移库在途中，原公司不能操作，新公司能够操作*/
                    if(item.state=='移库在途'&& item.auditFlag==1 && that.partTime.indexOf(item.newCompanyId)>=0 && item.moveNewCompanyId != item.newCompanyId){//
                        return false;
                    }
                    if(
                        that.itemIndexOf("服务工程师",item) ||
                        (
                            item.state=='移库在途' &&
                            (
                                that.partTime.indexOf('服务工程师' + item.moveNewCompanyId)>=0
                                ||
                                that.partTime.indexOf('服务工程师' + "201712161613432EAF27DBCCB7D0E6CA")>=0
                            )
                        )
                    ){
                        return (
                            /*服务工程师接车*/
                            (
                                /*草稿，审核通过*/
                                (item.auditFlag =='-1'||item.auditFlag=='1') &&
                                /*在途过程*/
                                (item.state=='提车在途'||item.state=='退货在途'||item.state=='移库在途')
                            )
                            ||
                            /*接完车后要审核*/
                            (
                                /*库存，寄存*/
                                (item.state=='库存'||item.state=='寄存') &&
                                /*草稿、已驳回*/
                                (item.auditFlag=='-1'||item.auditFlag=='2')
                            )
                        );

                    }
                    if(that.itemIndexOf("销售管理",item)){
                        return (
                            (
                                item.state=='待出库'&&item.auditFlag=='1'
                            )
                            ||
                            (
                                item.state=='交付在途'&&item.auditFlag!='0'
                            )
                            ||
                            (
                                item.state=='已交'&&(item.auditFlag=='-1'||item.auditFlag=='2')
                            )
                            ||
                            (
                                item.state=='移库在途' && item.auditFlag=='2'
                            )
                        );
                    }
                }
                return false;
            },

            del: function (id) {
                if (confirm('确认要删除吗？')) {
                    var that = this;
                    $.wyui.postMethod("/deviceSample/delById.json", {id: id}, function (result) {
                        if(result.isOk){
                            alert("删除成功");
                        }
                        that.sel();
                    });
                }
            },
//            查询
            search: function () {
                var that = this;
                if (that.selectState == "已交") {
                    that.Tag = 0;
                } else {
                    that.Tag = 1;
                }

                var data = {
                    userId: getCurrentUser().id,
                    'state': that.selectState == '全部' ? '' : that.selectState
                };

                $.wyui.postMethod('/deviceSampleNew/getDeviceSampleList.json', data, function (r) {
                    that.list = r.records;
                })
            },
            /*根据companyId获取品牌*/
            getType: function () {
                var that = this;
                that.selectType = '请选择设备类型';
                that.selectMod = '请选择型号';
                that.selectStock = '请选择库存地';
                that.selectBucket = '请选择铲斗配置';
                var s = that.selectCom;
                var b = that.selectBran;
                var data = {'companyId': s.toString(), 'brandId': b.toString()};
                $.wyui.postMethod('/deviceBrand/getDeviceTypeList.json', data, function (r) {
                    $("#selBran").hide();
                    $("#selType").hide();
                    that.itemsType = r.devicetypes;
                });
                $.wyui.postMethod('/deviceBrand/getBankAndAccount.json', {brandId: that.selectBran}, function (data) {
                    that.payees = data;
                });
                $.wyui.postMethod('/brandStrock/selectByBrandId.json', {
                    brandId: that.selectBran,
                    type: 'distinct'
                }, function (data) {
                    that.factorys = data;
                    that.selectType = '设备类型';
                    that.selectMod = '型号';
                });
            },
//            获取公selectBran司
            getBran: function () {
                var that = this;
                var s = that.selectCom;
                that.selectBran = '请选择品牌';
                that.selectType = '请选择设备类型';
                that.selectMod = '请选择型号';
                that.selectStock = '请选择库存地';
                that.selectBucket = '请选择铲斗配置';
                var data = {'companyId': s.toString()};
                $.wyui.postMethod('/deviceBrand/getBrandByCompanyId.json', data, function (r) {
                    that.itemsBran = r.brands;
                    that.selectBran = '品牌';
                    that.selectType = '设备类型';
                    that.selectMod = '型号';
                })
                $.wyui.postMethod('/company/getCompanyById.json', {id: s.toString()}, function (r) {
                    that.stocks = r.stock;
                })
            },
            /*根据brandId获得型号*/
            getMod: function () {
                var that = this;
                if ($("#testType option:selected").text().indexOf("挖掘机") >= 0 | $("#testType option:selected").text().indexOf("装载机") >= 0) {
                    $("#wjj").show();
                    $("td[name='psc']").hide();
                    $("td[name='sfj']").hide();
                } else if ($("#testType option:selected").text().indexOf("破碎锤") >= 0) {
                    $("#wjj").hide();
                    $("td[name='sfj']").hide();
                    $("td[name='psc']").show();
                } else if ($("#testType option:selected").text().indexOf("筛分机") >= 0 | $("#testType option:selected").text().indexOf("破碎机") >= 0) {
                    $("td[name='psc']").hide();
                    $("#wjj").hide();
                    $("td[name='sfj']").show();
                }
                that.selectMod = '请选择型号';
                that.selectStock = '请选择库存地';
                that.selectBucket = '请选择铲斗配置';
                var deviceTypeId = that.selectType;
                var brandId = that.selectBran;
                that.buckets = "";
                var data = {'brandId': brandId, 'deviceTypeId': deviceTypeId};
                $.wyui.postMethod('/deviceModel/getModelListByBrandId.json', data, function (r) {
                    that.itemsMod = r.models;
                    that.selectMod = '型号';
                })
            },
            show: function () {
                var that = this;
                var deviceTypeId = that.selectType;
                var brandId = that.selectBran;
                var modelId = that.selectMod
                var type = that.type
                var index = that.index;//防止上传按钮多次渲染
                that.selectBucket = "请选择铲斗配置"
                $.wyui.postMethod('/deviceBucket/getListBymodelId.json', {modelId: that.selectMod}, function (r) {
                    that.buckets = r.buckets;
                })
                $.wyui.postMethod('/device/getDeviceById.json', {id: that.selectMod}, function (r) {
                    that.sampleParmsList.main.modelName = r.modelName;
                })
            },

            /*根据选中条件查询设备信息(无法获取传回来的records)*/
            sel: function () {
                var that = this;
                var obj;
                if (that.settle) {
                    obj = "是";
                } else {
                    obj = "";
                }
                var optionsCom = $("#testCom option:selected").text();
                var optionsType = $("#testType option:selected").text();
                var optionsBran = $("#testBran option:selected").text();
                var optionsMod = $("#testMod option:selected").text();
                var data = {
                    'companyName': optionsCom,
                    'brandName': optionsBran,
                    'modelName': optionsMod,
                    'deviceTypeName': optionsType,
                    userId: getCurrentUser().id,
                    'key': that.key,
                    'state': that.selectState == '全部' ? '' : that.selectState,
                    'settle': obj,
                };
                $.wyui.postMethod('/deviceSampleNew/getDeviceSampleList.json', trimRN(data), function (r) {
                    that.list = r.records;
                    that.num = r.num;

                })
            },
            isShow: function (item) {
                var that=this;
                if(that.roleName=='销售管理'&&getCurrentUser().companyId==item.newCompanyId ||
                    item.partTime=='销售管理'&&item.newCompanyId==item.fkcompanyId){
                    return true;
                }
            },
            /*判断是否显示出库*/
            showABtn: function (item, type) {
                var that=this;
                if (item.auditFlag == 0 || item.auditFlag==2 ) {
                    return false;
                } else {
                    switch (item.state) {
                        case '库存':
                            switch (type){
                                case 'move':
                                    if(that.itemIndexOf('销售管理',item)){
                                        return true;
                                    }
                                    break;
                                default:
                                    return true;
                            }
                            break;
                        case '寄存':
                            switch (type){
                                case 'move':
                                    if(that.itemIndexOf('销售管理',item)){
                                        return true;
                                    }
                                    break;
                                default:
                                    return true;
                            }
                            break;
                        case '已交':
                            switch (type) {
                                case 'exit':
                                    return true;
                                    break;
                            }

                    }
                }

            },
            /*判断状态为已出库或草稿时显示红色*/
            convertAuditFlagToName: function (item) {
                switch (item.state) {
                    case "已交":
                        return "<span style='color:red;'>" + item.state + "</span>";
                        break;
                    case "库存":
                        return "<span style='color:white;background-color:#8c8c8c'>" + item.state + "</span>";
                        break;
                    default :
                        return "<span>" + item.state + "</span>";
                        break;
                }
            },
            gotoDetail: function (item) {

                var that=this;
                if((item.state=='待出库' || (item.state=='交付在途'&&item.auditFlag==2)) && that.itemIndexOf("销售管理",item)){
                    var url='url:/page/device-new/sample/outBound.html?sampleId=' + item.id
                        + "&&storeAddress=" + item.storeAddress
                        + "&&modelName=" + item.modelName
                        + "&&type=" + 'out'
                        + "&&contact=" + item.contactName
                        + "&&contactTel=" + item.contactTel
                        + "&&pickUpAddress=" + item.pickUpAddress
                        + "&&companyId="+item.newCompanyId
                        + "&&roleName=销售管理";
                    top.$.dialog({
                        content:url ,
                        title: '新机出库',
                        width: 904,
                        height: 565,
                        max: true,
                        min: true,
                        lock: true
                    })
                }else if(that.itemIndexOf("销售管理",item) && item.state=='移库在途' && item.auditFlag==2){
                    that.gotoDetailOut(item,'move')
                }else {
                    top.closeTabByPageId("xjgl");
                    var roleName= that.itemIndexOf("订货支持",item)?'订货支持':
                        that.itemIndexOf("销售管理",item)?"销售管理":
                            that.itemIndexOf("服务工程师",item)?"服务工程师":"";
                    var url = '/device-new/sample/detailNew.html?pageType=edit&&id=' + item.id
                        + "&&auditFlag=" + item.auditFlag
                        + "&&state=" + item.state
                        + "&&storeAddress=" + item.storeAddress
                        + "&&roleName=" + roleName;
                    top.addTabs({
                        id: 'xjgl',
                        title: '新机编辑',
                        close: true,
                        url:url
                    });
                }
            },
            gotoDetailSh: function (id) {
                top.closeTabByPageId("xjgl");
                top.addTabs({
                    id: 'xjgl',
                    title: '新机审核',
                    close: true,
                    url: '/device-new/sample/detailNew.html?pageType=look&&id=' + id+"&&roleName=订货支持&&auditFlag=0"
                });
            },
            gotoDetailSel: function (item) {
                top.closeTabByPageId("xjgl");
                var roleName="订货支持,销售管理,服务工程师".indexOf(this.roleName)>-1?this.roleName:item.partTime;
                top.addTabs({
                    id: 'xjgl',
                    title: '新机详情',
                    close: true,
                    url: '/device-new/sample/detailNew.html?pageType=look&&id=' + item.id+"&roleName="+roleName
                });
            },
            gotoDetailOut: function (item, type) {
                var title = "";
                var roleName="订货支持";
                if (type == "out") {
                    title = "新机出库"
                } else if (type == "move") {
                    title = "新机移库"
                    roleName="销售管理"
                } else {
                    title = "新机退货"
                }
                top.$.dialog({
                    content: 'url:/page/device-new/sample/outBound.html?sampleId=' + item.id + "&&storeAddress=" + item.storeAddress + "&&modelName=" + item.modelName + "&&type=" + type + "&&contact=" + item.contactName + "&&contactTel=" + item.contactTel + "&&pickUpAddress=" + item.pickUpAddress+"&pageType=add&&state="+item.state+"&roleName="+roleName+"&&companyId="+item.newCompanyId,
                    title: title,
                    width: 904,
                    height: 565,
                    max: true,
                    min: true,
                    lock: true
                })
            },

            addNewSample: function () {
                top.closeTabByPageId("xjgl");
                top.addTabs({
                    id: 'xjgl',
                    title: '新机入库',
                    close: true,
                    url: "/device-new/sample/detailNew.html?pageType=add&roleName=订货支持"
                });
            },
            isActive: function (item) {
                var that = this;
                if (that.num == item) {
                    return true;
                }
            },
        },
        mounted: function () {
            $(".oaLoad").show();
            var that = this;
            that.state = 1;
            /*获取兼职信息*/
            $.wyui.postMethod("/user/getAllByUserId.json", {userId: getCurrentUser().id}, function (r) {
                r = r.result;
                for(var i = 0;i<r.length;i++){
                    that.partTime += ',' + r[i]['roleName']+r[i]['companyId'];
                }
                if(that.partTime.indexOf('订货支持')==-1){
                    $("#add,#export").hide();
                }
            },true)
            $.wyui.postMethod('/deviceSampleNew/getDeviceSampleList.json', {userId: getCurrentUser().id}, function (r) {
                that.list = r.records
                that.num = r.num;
                for (var i = 0; i < that.stateList.length; i++) {
                    if (that.stateList[i].name == '全部') {
                        that.stateList[i].name = '全部' + '(' + that.num.allNum + ')';
                    } else if (that.stateList[i].name == '未发订单') {
                        that.stateList[i].name = '未发订单' + '(' + 0 + ')';
                    } else if (that.stateList[i].name == '提车在途') {
                        that.stateList[i].name = '提车在途' + '(' + that.num.getNow + ')';
                    } else if (that.stateList[i].name == '库存') {
                        that.stateList[i].name = '库存' + '(' + that.num.no + ')';
                    } else if (that.stateList[i].name == '待出库') {
                        that.stateList[i].name = '待出库' + '(' + that.num.willOutBound + ')';
                    } else if (that.stateList[i].name == '交付在途') {
                        that.stateList[i].name = '交付在途' + '(' + that.num.outNow + ')';
                    } else if (that.stateList[i].name == '已交') {
                        that.stateList[i].name = '已交' + '(' + that.num.outNum + ')';
                    } else if (that.stateList[i].name == '移库在途') {
                        that.stateList[i].name = '移库在途' + '(' + that.num.moveNow + ')';
                    } else if (that.stateList[i].name == '退货在途') {
                        that.stateList[i].name = '退货在途' + '(' + that.num.exitNum + ')';
                    } else if (that.stateList[i].name == '已退货') {
                        that.stateList[i].name = '已退货' + '(' + that.num.exitNow + ')';
                    }
                }
                $(".oaLoad").hide();
            })
            $.wyui.postMethod('/company/getCompanyByUserId.json', {userId: that.userId}, function (r) {
                that.itemsCom = r;
            });
            $.wyui.postMethod('/deviceBrand/getBrandByCompanyId.json', {}, function (r) {
                that.itemsBran = r.brands;
            })
        },

    });
    $('#btnQuery').on('click', function () {
        var key = $("#likeSelect").val();
        $.wyui.postMethod('/deviceSampleNew/getDeviceSampleList.json', {
            userId: getCurrentUser().id,
            key: $.trim(key)
        }, function (r) {
            app.list = r.records
            app.num = r.num;
        })
    });
    $("input[type='text']").keypress(function (e) {
        if (event.keyCode == 13) {
            event.cancelBubble = true;
            event.returnValue = false;
            $(this).parents("div").find("#btnQuery").click();
        }
    });
</script>
<script>
    /************************滚动加载******************************/
    var divscroll = document.getElementById('scrollDiv');

    function divScroll() {
        var wholeHeight = divscroll.scrollHeight;
        var scrollTop = divscroll.scrollTop;
        var divHeight = divscroll.clientHeight;
        console.log(scrollTop + divHeight, wholeHeight)
        if (scrollTop + divHeight >= wholeHeight - 2) {
//            alert('滚动到底部了！');
            if (isLoad) {
                isLoad = false;
                setTimeout($.wyui.page.getByPage("scroll"), 1000);

            }

            //这里写动态加载的逻辑，比如Ajax请求后端返回下一个页面的内容
        }

    }

    divscroll.onscroll = divScroll;
</script>
<script>
    //初始化FixedTable
    $(".fixed-table-box").fixedTable();
</script>
</body>
</html>